<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>优惠券详细新增</title>
<%@include file="../include/include.jsp"%>
<link rel="stylesheet" type="text/css" href="${csspath }/public.css" />
<script type="text/javascript" src="${layerPath}/jquery/jquery-1.8.3.js"></script>
<link rel="stylesheet" type="text/css"
	href="${bootstrapPath}/css/bootstrap.css" />
<script type="text/javascript" src="${bootstrapPath}/js/bootstrap.js"></script>
<script type="text/javascript"
	src="${bootstrapPath}/js/bootstrap3-validation.js"></script>
</head>
<style>
.labelShow {
	float: left;
	width: 20%;
	line-height: 30px;
	text-align: right;
}

.inputDiv {
	float: left;
	width: 50%;
}

.main {
	position: relative;
	margin: 0 auto;
	padding: 10px 10px;
	width: 570px;
	height: 350px;
}
</style>

<script type="text/javascript">
	$(function() {

		$("#couponLineForm").validation({
			icon : true
		});
		$("#exitBtn")
				.click(
						function() {
							var ticketDefId = $("#ticketDefId").val();
							var qticketType = $("#qticketType").val();
							var qticketName = $("#qticketName").val();
							var pager = $("#pager").val();
							parent.location.href = '${webcontext}/crmdp/dealer/coupon/toEditTicket?ticketDefId='
									+ ticketDefId
									+ "&qticketType="
									+ qticketType
									+ "&qticketName="
									+ qticketName
									+ "&pager.currentPage="
									+ pager;
						});
		$("#saveBtn")
				.click(
						function() {
							if ($("#couponLineForm").valid(this) == false) {
								return false;
							}
							$
									.ajax({
										url : '${webcontext}/crmdp/dealer/coupon/insertTiketLineInfo',
										type : 'post',
										data : {
											'ticketDefId' : $("#ticketDefId")
													.val(),
											'itemName' : $("#itemName").val(),
											'quantity' : $("#quantity").val()
										},
										success : function(data) {
											if (data.code == true) {
												jAlert(
														data.msg,
														"提示",
														function() {
															var ticketDefId = $(
																	"#ticketDefId")
																	.val();
															var qticketType = $(
																	"#qticketType")
																	.val();
															var qticketName = $(
																	"#qticketName")
																	.val();
															var pager = $(
																	"#pager")
																	.val();
															parent.location.href = '${webcontext}/crmdp/dealer/coupon/toEditTicket?ticketDefId='
																	+ ticketDefId
																	+ "&qticketType="
																	+ qticketType
																	+ "&qticketName="
																	+ qticketName
																	+ "&pager.currentPage="
																	+ pager;
															;
														});
											} else if (data.code == false) {
												jAlert(data.msg, "提示");
											}
										},
										error : function() {
											jAlert("服务器错误，请联系管理员", "提示");
										},
									});
						});
	});
</script>
<body>
	<div class="main">
		<form:form class="form-horizontal" id="couponLineForm" method="post"
			action="" modelAttribute="dto" role="form">
			<input type="text" id="ticketDefId" name="ticketDefId" value="${ticketDefId}" class="hidden" />


			<input type="text" class="hidden" id="qticketType" name="qticketType"
				value="${qticketType}" />
			<input type="text" class="hidden" id="qticketName" name="qticketName"
				value="${qticketName}" />
			<input type="text" class="hidden" id="pager" name="pager.currentPage"
				value="${currentPage}">

			<div class="form-group">
				<label for="itemName" class="col-sm-2 control-label labelShow">产品说明</label>
				<div class="col-sm-5 inputDiv">
					<input type="text" class="form-control" id="itemName"
						check-type="required" />
				</div>
			</div>
			<div class="form-group">
				<label for="quantity" class="col-sm-2 control-label labelShow">数量</label>
				<div class="col-sm-5 inputDiv">
					<input type="text" class="form-control" id="quantity"
						check-type="number" />
				</div>
			</div>
			<div class="form-group text-center" style="margin-left: -100px;">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="button" class="btn btn-success" id="saveBtn">保存</button>
					<button type="button" class="btn btn-success" id="exitBtn">取消</button>
				</div>
			</div>
		</form:form>
	</div>
</body>
</html>